<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>选择会员</title>
	<!-- ICON -->
	<link href="/frame/images/meatball.ico" type="image/ico" rel="shortcut icon">
	<!-- CSS -->
	<link rel="stylesheet" href="/lib/layuiadmin/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/lib/layuiadmin/css/admin.css" media="all" />

</head>
<body layadmin-themealias="default">
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body">
			<div class="layui-row">
				<div class="layui-col-md2">
					<!--<form class="layui-form" style="float: left;">-->
<!--                    <div class="layui-inline">-->
<!--                        <button class="layui-btn layui-btn-warm" lay-submit lay-filter="enableJobBtn" title="开启">-->
<!--                            <i class="layui-icon">&#xe61f;</i>开启-->
<!--                        </button>-->
<!--                    </div>-->
					<!--</form>-->
				</div>
				<div class="layui-col-md10">
					<form class="layui-form" id="queryForm" style="float: right;">
                        <div class="layui-inline">
                            <input type="text" name="yhbm" title="会员编号" placeholder="请输入会员编号" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline">
							<input type="text" name="xm" title="姓名" placeholder="请输入姓名" autocomplete="off" class="layui-input">
						</div>
                        <div class="layui-input-inline">
                            <select id="select_lx"  name="lx" title="类型">
                                <option value="">全部</option>
                                <option value="2">A养殖场</option>
                                <option value="0">B管理员</option>
                                <option value="3">C担保方</option>
                                <option value="1">D经销商</option>
                            </select>
                        </div>
						<button id="btn_query" class="layui-btn" lay-submit lay-filter="query">
							<i class="layui-icon">&#xe615;</i> 查询
						</button>
						<!--<button class="layui-btn" lay-submit lay-filter="crontimebtn2">-->
							<!--<i class="layui-icon">&#xe615;</i> cron-->
						<!--</button>-->
					</form>
				</div>
			</div>
			<hr class="layui-bg-gray">
			<div class="layui-row">
				<div class="layui-col-md12">
					<!-- 表格 -->
					<table id="table" lay-filter="table"></table>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- 操作 -->
<script type="text/html" id="operationBar">
  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="select_user">选择</a>
</script>

<!-- 状态操作 -->
<!--<script type="text/html" id="taskstatus">-->
<!--	<input type="checkbox" id="{{d.id}}" name="taskstatus" value="{{d.taskstatus}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="switchSysTaskStatus" {{ d.taskstatus == 1 ? 'checked' : '' }}>-->
<!--</script>-->

<!--<script type="text/html" id="triggerstatus">-->
<!--	<input type="checkbox" id="{{d.id}}" name="triggerstatus" value="{{d.triggerstatus}}" lay-skin="switch" lay-text="正常|停止" lay-filter="switchTriggerStatus" {{ d.triggerstatus == 1 ? 'checked' : '' }}>-->
<!--</script>-->
<!-- 状态操作 -->

<!--<script type="text/html" id="triggertype">-->
<!--	<input type="checkbox" id="{{d.id}}" name="triggertype" value="{{d.triggertype}}" lay-skin="switch" lay-text="Cron|Simple" lay-filter="switchTriggerType" {{ d.triggertype == 1 ? 'checked' : '' }}>-->
<!--</script>-->


<!-- 详情 -->
<script type="text/html" id="view">
<table class="layui-table" style="width: 680px; margin: 10px 10px 0px 10px;">
	<tr><td class="table-td-title">会员编号</td><td width="465">{{d.yhbm ||''}}</td></tr>
	<tr><td class="table-td-title">会员姓名</td><td width="465">{{d.xm ||''}}</td></tr>
	<tr><td class="table-td-title">手机号</td><td width="465">{{d.mobile ||''}}</td></tr>
	<tr><td class="table-td-title">身份账号</td><td width="465">{{d.sfzh ||''}}</td></tr>
	<tr><td class="table-td-title">性别</td><td width="465">{{d.sex ||''}}</td></tr>
	<tr><td class="table-td-title">类型</td><td width="465">
        {{d.lx == 2 ? 'A养殖场 ' : ''}}
        {{d.lx == 0 ? 'B管理员 ' : ''}}
        {{d.lx == 3 ? 'C担保方 ' : ''}}
        {{d.lx == 1 ? 'D经销商 ' : ''}}
        </td>
    </tr>
    <tr><td class="table-td-title">子账号</td><td width="465">{{d.subno ||''}}</td></tr>
    <tr><td class="table-td-title">余额</td><td width="465">{{d.totalmoney ||''}}</td></tr>
    <tr><td class="table-td-title">提现余额</td><td width="465">{{d.withdrawmoney ||''}}</td></tr>
    <tr><td class="table-td-title">银行卡号</td><td width="465">{{d.yhkh ||''}}</td></tr>
    <tr><td class="table-td-title">卡号类型</td><td width="465">{{d.yhklx ||''}}</td></tr>
    <tr><td class="table-td-title">银行名称</td><td width="465">{{d.yhmc ||''}}</td></tr>
    <tr><td class="table-td-title">银行代码</td><td width="465">{{d.yhdm ||''}}</td></tr>
    <tr><td class="table-td-title">绑定状态</td><td width="465">{{d.bdzt ||''}}</td></tr>
</table>

<br>
</script>


<!-- JavaScript -->
<script type="text/javascript" src="/lib/layuiadmin/layui/layui.js"></script>

<script th:inline="javascript">
	var user_flag = [[${user_flag}]];
</script>

<script type="text/javascript" th:inline="none">
layui.config({
	base: '/lib/layuiadmin/' //静态资源所在路径
}).extend({
	index: 'lib/index' //主入口模块
}).use(['index', 'upload'], function() {

	var table = layui.table,
		form = layui.form,
		laydate = layui.laydate,
		upload = layui.upload,
		element = layui.element,
		laytpl = layui.laytpl,
		$ = layui.jquery,
		// $addBtn = $('#addBtn'),
		$queryForm = $('#queryForm'),
		layerIndex = 1;

	var query_lx = '';
	if(user_flag=='A'){
		query_lx = '2';
		// $("#select_lx").find("option"[value='2']).attr("Selected",true);
	}
	if(user_flag=='B'){
		query_lx = '0';
		// $("#select_lx").find("option"[value='0']).attr("Selected",true);
	}
	if(user_flag=='C'){
		query_lx = '3';
		// $("#select_lx").find("option"[value='3']).attr("Selected",true);
	}
	if(user_flag=='D'){
		query_lx = '1';
		// $("#select_lx").find("option"[value='1']).attr("Selected",true);
	}
	$('#select_lx').val(query_lx);
	form.render('select');

	// $('#btn_query').click();

	// 绘制表格
	table.render({
// 		id: 'table',
		elem: '#table',
		url: '/pig/user/table?qlx='+query_lx,
		page: true, // 开始分页/pig/user
		// cellMinWidth: 80, // 定义全局最小宽度
		request: {
			pageName: 'offset'
		},
		response: {
            statusCode: 10000
          // countName: 'total', //数据总数的字段名称，默认：count
          // dataName: 'list' //数据列表的字段名称，默认：data
		},
		cols: [[
			{type: 'numbers', title: '序号',fixed: 'left'},
			{field:'yhbm', title: '编号',width:80,fixed: 'center', sort: true},
			{field:'xm', title: '会员姓名', width:100,fixed: 'center'},
			{field:'mobile', title: '手机号', width:150,fixed: 'center'},
			{field:'sfzh', title: '身份账号', width:200},
			{field:'sex', title: '性别', width:60},
			{field:'lx', title: '类型',align:'center', width:120,templet:
                    function (d) {
                        if (d.lx == 0) {
                            return "B管理员";
                        } else if (d.lx == 1) {
                            return "D经销商";
                        } else if (d.lx == 2) {
                            return "A养殖场";
                        }else if (d.lx == 3) {
                            return "C担保方";
                        }
                        return "";
                    }
                },
            {field:'subno', title: '子账号', width:200},
            {field:'totalmoney', title: '余额', width:100},
            {field:'withdrawmoney', title: '提现余额', width:100},
            {field:'yhkh', title: '银行卡号', width:200},
            {field:'yhklx', title: '卡号类型', width:100},
            {field:'yhmc', title: '银行名称', width:100},
            {field:'yhdm', title: '银行代码', width:100},
            // {field:'bdzt', title: '绑定状态', width:100},

			{fixed: 'right', align:'center', width: 180, toolbar: '#operationBar'}
		]]
	});
	//监听工具条
	table.on('tool(table)', function(obj) {

		var data = obj.data,
			$this = $(this),
			getView = view.innerHTML;
		if(obj.event === 'detail') {
			$.get('/pig/user/' + data.yhbm, function(res) {
				if(res.code == 403) {
					layer.msg(res.message, {icon: 4});
				} else {
					laytpl(getView).render(res, function(html) {
						popupWin($this.text(), html, false);
					})
				}
			})
		} else if(obj.event === 'select_user') {
            let a=parent.ChooseValues(user_flag,data);//注意这里调用父层的JS 实现传值
            var index= parent.layer.getFrameIndex(window.name);//获取当前层
            parent.layer.close(index);//关闭当前层
            return false;
        }
	});


	// 搜索条件提示
	$queryForm.find('input').on('mouseover', function() {
		if(typeof($(this).attr('title')) == 'undefined') return;
		layer.tips($(this).attr('title'), this, {tips: 1});
	});

	// 查询
	form.on('submit(query)', function(data) {
		table.reload('table', {
			where: data.field
		});
		return false;
	});

	function operate(ajaxType, data, refresh, delRow) {
		var url = '/pig/user/';
		$.ajax({
			url: url,
		    type: ajaxType,
		    async: true,
		    data: data,
		    success: function(res) {
		    	if(res.code == 10000) {
					layer.close(layerIndex);
					if(refresh) {
		    			table.reload('table');
					} else if(ajaxType == 'DELETE') {
						delRow.del();
					}
		    		if(data.resetPwd) {
		    			layer.alert(res.message, {icon: 6});
		    		} else {
						layer.msg(res.message, {icon: 1});
		    		}
		    	}  else if(res.code == 403) {
		    		layer.msg(res.message, {icon: 4});
		    	} else {
		    		layer.msg(res.message, {icon: 5});
		    	}
		    }
		})
	}

	//渲染弹框
	function popupWin(title, content, showBtn) {
		layerIndex = layer.open({
			id: 'meatball',
			type: 1, //Page层类型
			area: '700px', //['700px', '480'],
			maxWidth: 1000,
			maxHeight: 800,
			title: title,
            skin: 'layui-layer-rim', //加上边框
			shade: 0.1, //遮罩透明度
			// maxmin: true, //允许全屏最小化
			anim: 0, //0-6的动画形式，-1不开启
			scrollbar: false, //禁用滚动
			content: content,
			btn: showBtn ? ['<i class="layui-icon layui-icon-ok"></i> 提交', '<i class="layui-icon layui-icon-refresh-1"></i> 重置'] : '',
			yes: function(index, layero) {
				layero.find('form .submit').trigger('click');
				return false;
			},
			btn2: function(index, layero) {
				layero.find('form .reset').trigger('click');
				return false;
			}
		});
        // layer.full(layerIndex);
	}

	// 动态渲染控件
	function rendering() {
		var $form = $('form');
		// 渲染select
		form.render('select');
		// 重新渲染多选框
		form.render('checkbox');
		// // 初始化日期
		// laydate.render({
		// 	elem: '.birthday'
		// });

	}
});
</script>
</body>
</html>